Differential Expression Analysis

1 Introduction

Differential Gene Expression (DGE) refers to the process of identifying and quantifying changes in gene expression levels between different biological conditions, such as healthy vs diseased states, treated vs untreated samples, different developmental stages or distinct cell types. Understanding DGE is fundamental in fields like molecular biology, genetics, and biomedical research, as it provides insights into how genes contribute to various biological processes and phenotypes.

Tumor Necrosis Factor (TNF) is a pro-inflammatory cytokine, crucial for the regulation of the immune system’s healthy inflammatory reactions. However, when in overproduction or dysregulation, TNF can contribute to chronic inflammation implicated in various autoimmune and inflammatory diseases, hence the now widespread use of anti-TNF drugs to treat such conditions, also known as TNF inhibitors (Monaco et al. 2014). Despite the success of anti-TNF agents in treating chronic pathological inflammatory reactions, little is known about their impact on the affected tissues at the transcriptome level. As an endeavor to discover the effects of such drugs on the expression levels of different genes, Karagianni and colleagues applied four different anti-TNF drugs on an established mouse model of inflammatory polyarthritis and collected a large number of independent biological replicates from the synovial tissue of healthy, diseased and treated animals (Karagianni et al. 2019). The dataset that pertains to these experiments is used in this workflow, which is part of the study’s computational analyses for identifying and clustering differentially expressed genes. Expression levels were detected and quantified with DNA microarrays, where detected fluorescence indicates the expression of a specific gene against a reference sample.

2 Exploratory Data Analysis

Exploratory Data Analysis (EDA) is a critical process in data science and statistics that involves analyzing and summarizing the main characteristics of a dataset, often using visual methods. The goal of EDA is to uncover patterns, spot anomalies, test hypotheses, and check assumptions with the help of summary statistics and graphical representations (Morgenthaler 2009).

Code
knitr::opts_chunk$set(message = FALSE, warning = FALSE)
options(warn = -1)

suppressPackageStartupMessages({
  library(preprocessCore)
  library(umap)
  library(ggplot2)
  library(multcomp)
  library(gplots)
  library(factoextra)
  library(dplyr)
  library(kableExtra)
  library(gprofiler2)
  library(randomForest)
  library(caret)
  library(cowplot)
  library(RColorBrewer)
  library(plotly)
})
Code
# Read file
data = read.delim(file = "Raw_common18704genes_antiTNF.tsv",
                  header = T, 
                  row.names = 1,
                  sep = "\t")

# Keep gene and sample names
Gene = rownames(data)
Sample = colnames(data)
Code
boxplot(data, horizontal = T, las = 1, cex.axis = 0.5)
Figure 1: Boxplot of data before quantile normalization
Code
# Show head of dataframe
kable(head(data)) |>
  kable_styling(bootstrap_options = c("striped")) |>
  scroll_box(width = "100%", height = "100%") |>
  kable_classic()
Exp1Wt_1 Exp1Wt_2 Exp1Wt_3 Exp2Wt_1 Exp2Wt_2 Exp2Wt_3 Exp2Wt_4 Exp3Wt_1 Exp3Wt_2 Exp3Wt_3 Exp1Tg_1 Exp1Tg_2 Exp1Tg_3 Exp2Tg_1 Exp2Tg_2 Exp2Tg_3 Exp2Tg_4 Exp3Tg_1 Exp3Tg_2 Exp3Tg_3 Exp4Tg_1 Exp4Tg_2 Exp4Tg_3 Exp1Rem3_1 Exp1Rem3_2 Exp1Rem3_3 Exp1Rem6_1 Exp1Rem6_2 Exp1Rem6_3 Exp2Rem6_1 Exp2Rem6_2 Exp2Rem6_3 Exp2Rem6_4 Exp3Rem6_1 Exp3Rem6_2 Exp3Rem6_3 Exp2Hum6_1 Exp2Hum6_2 Exp2Hum6_3 Exp2Hum6_4 Exp3Hum6_1 Exp3Hum6_2 Exp3Hum6_3 Exp4Hum6_1 Exp4Hum6_2 Exp4Hum6_3 Exp2Enb6_1 Exp2Enb6_2 Exp2Enb6_3 Exp2Enb6_4 Exp4Enb6_1 Exp4Enb6_2 Exp4Enb6_3 Exp4Enb6_4 Exp4Enb6_5 Exp4Enb6_6 Exp2Cim6_1 Exp2Cim6_2 Exp2Cim6_3 Exp2Cim6_4 Exp4Cim6_1 Exp4Cim6_2 Exp4Cim6_3 Exp4Cim6_4 Exp4Cim6_5 Exp4Cim6_6
A1bg 3.78911 3.90081 3.72526 4.23290 4.14451 4.17460 4.19904 4.37631 4.35622 4.35167 3.78454 4.07887 4.13286 4.05313 4.20157 4.18684 4.27081 4.50461 4.29096 4.36422 3.74793 3.74200 3.79036 3.59538 3.96438 3.79821 3.55839 3.72886 3.73221 4.00460 4.06560 4.10832 4.14768 4.45705 4.40942 4.29107 4.23619 4.11532 4.04981 4.05459 4.38727 4.36555 4.49019 3.55204 3.45422 3.75162 4.11680 4.11782 4.09583 4.05194 3.70226 3.75635 3.82224 3.39433 3.74648 3.48890 4.11928 4.14522 4.10418 4.10931 3.61480 3.37258 3.58425 3.88982 3.28356 4.04937
A1cf 4.21654 4.17014 4.05211 4.60213 4.62320 4.65975 4.57693 4.15842 4.21211 4.18009 3.98771 4.11709 4.10684 4.68407 4.63325 4.73126 4.67542 4.09641 3.97244 4.10268 3.30531 3.29409 3.06133 4.29460 4.22492 4.08466 4.08205 4.13011 4.09484 4.62164 4.66620 4.61722 4.55999 4.38385 4.06813 4.13370 4.53864 4.75150 4.64363 4.68842 4.03449 4.62612 4.24503 3.39752 3.35704 3.31550 4.61107 4.71722 4.65451 4.68732 3.34686 3.26266 3.04503 3.16430 3.13805 3.10227 4.65152 4.67835 4.67399 4.61035 2.90180 3.27259 3.02554 3.12053 3.08666 3.24268
A2ld1 5.32714 5.62827 5.66799 8.32861 8.27225 8.27447 8.42341 8.22626 8.39943 8.57076 5.23156 5.29504 5.28384 7.90894 7.85233 8.14223 7.79835 7.90913 8.08984 7.95827 6.55196 6.51255 6.43711 6.01249 5.46742 5.54192 5.56968 5.70214 5.46825 8.26541 8.30650 8.22540 8.09633 8.30025 7.86106 7.86827 8.19100 8.37507 8.20061 8.27231 8.39751 8.30546 8.49839 6.69627 6.52055 6.64086 8.00233 8.18752 8.25757 8.03628 6.43991 6.62674 6.80411 6.40195 6.77547 6.49056 8.09591 8.09534 8.08303 8.07122 6.51077 6.56018 6.40339 6.71310 6.35072 6.61334
A2m 5.28545 6.49319 5.19705 6.34696 5.68818 7.02162 6.30722 7.24319 6.80225 6.69186 4.71382 5.03411 5.41249 6.57654 6.10905 6.11674 5.67339 6.93047 6.70562 6.65830 5.29271 5.47738 6.79552 6.19873 5.40119 6.48264 5.78780 5.32115 5.44562 6.88086 5.34267 6.33201 6.39798 6.45636 6.43533 6.19721 6.10152 6.31918 5.95871 6.76260 6.76862 6.14994 5.71077 5.23411 5.38092 5.36692 5.98963 5.63186 5.84172 5.34126 5.51386 5.58334 5.51965 5.63152 5.64672 6.46401 5.42400 6.97807 6.39452 5.24073 4.64791 4.64806 6.10691 5.04173 4.90970 4.32605
A3galt2 4.59905 4.59698 4.52439 4.85959 5.07224 5.01061 5.07838 5.62244 5.79039 5.66514 4.73714 4.90568 5.18567 4.95670 4.65065 4.95141 4.96971 5.23615 5.38050 5.49452 4.72958 4.78397 4.66467 4.41278 4.82166 4.49756 4.54898 4.53977 4.85098 4.89872 4.96186 5.01156 5.02533 5.50526 5.51928 5.52995 5.12319 5.15686 5.02892 4.91145 5.58904 5.62234 5.64090 4.49644 4.98682 4.62059 4.94060 5.10253 4.92040 4.80770 4.63297 4.79730 4.73491 4.63326 4.78748 4.69899 4.96660 5.02830 4.96265 5.03972 4.70114 4.64965 4.50466 4.70696 4.55098 4.64297
A4galt 7.73303 7.65939 7.93984 8.55175 8.48415 8.47890 8.22892 8.72356 8.71276 8.58030 7.22117 7.00438 6.80762 8.65125 8.49504 8.61091 8.60534 8.90632 8.84868 8.88411 8.87908 8.68815 8.59815 7.98948 7.60469 7.47936 7.60934 7.44681 7.36165 8.70350 8.61929 8.80555 8.47461 8.76373 9.06743 9.36881 8.55062 8.73755 8.65360 8.69017 9.22244 9.12786 9.25526 8.76674 8.93546 8.86313 8.66064 8.60910 8.63829 8.86686 8.73614 8.96106 8.77789 8.77312 8.97563 8.70684 8.83717 8.88996 8.98343 8.75343 8.80162 8.76917 8.70345 8.80999 8.86269 8.62107

3 Check for missing values

If there are any missing values, we will need to decide how to handle them, probably by removing the respective genes.

Code
# Check genes_data for missing values
colSums(is.na(data))
  Exp1Wt_1   Exp1Wt_2   Exp1Wt_3   Exp2Wt_1   Exp2Wt_2   Exp2Wt_3   Exp2Wt_4 
         0          0          0          0          0          0          0 
  Exp3Wt_1   Exp3Wt_2   Exp3Wt_3   Exp1Tg_1   Exp1Tg_2   Exp1Tg_3   Exp2Tg_1 
         0          0          0          0          0          0          0 
  Exp2Tg_2   Exp2Tg_3   Exp2Tg_4   Exp3Tg_1   Exp3Tg_2   Exp3Tg_3   Exp4Tg_1 
         0          0          0          0          0          0          0 
  Exp4Tg_2   Exp4Tg_3 Exp1Rem3_1 Exp1Rem3_2 Exp1Rem3_3 Exp1Rem6_1 Exp1Rem6_2 
         0          0          0          0          0          0          0 
Exp1Rem6_3 Exp2Rem6_1 Exp2Rem6_2 Exp2Rem6_3 Exp2Rem6_4 Exp3Rem6_1 Exp3Rem6_2 
         0          0          0          0          0          0          0 
Exp3Rem6_3 Exp2Hum6_1 Exp2Hum6_2 Exp2Hum6_3 Exp2Hum6_4 Exp3Hum6_1 Exp3Hum6_2 
         0          0          0          0          0          0          0 
Exp3Hum6_3 Exp4Hum6_1 Exp4Hum6_2 Exp4Hum6_3 Exp2Enb6_1 Exp2Enb6_2 Exp2Enb6_3 
         0          0          0          0          0          0          0 
Exp2Enb6_4 Exp4Enb6_1 Exp4Enb6_2 Exp4Enb6_3 Exp4Enb6_4 Exp4Enb6_5 Exp4Enb6_6 
         0          0          0          0          0          0          0 
Exp2Cim6_1 Exp2Cim6_2 Exp2Cim6_3 Exp2Cim6_4 Exp4Cim6_1 Exp4Cim6_2 Exp4Cim6_3 
         0          0          0          0          0          0          0 
Exp4Cim6_4 Exp4Cim6_5 Exp4Cim6_6 
         0          0          0 

4 Data Distribution

Data distribution refers to how data values are spread or dispersed across a range of possible values. Understanding the distribution of the data is a key part of Exploratory Data Analysis (EDA), as it gives insights into the central tendency, variability, and shape of the dataset. It can help in detecting patterns, outliers, and important characteristics of the data, and also informs which statistical techniques to use. Thus, a detailed assessment of data distribution is a foundational step in unraveling the complexities of any dataset during the EDA process.

Central Tendency

  • Mean (Average): The sum of all values divided by the number of values. It provides a sense of the center of the data.

  • Median: The middle value when data is ordered. It’s less affected by extreme values (outliers) and provides a robust measure of the center.

  • Mode: The most frequent value in the data. For categorical data, this is often the only measure of central tendency.

Spread (Dispersion)

  • Range: The difference between the maximum and minimum values.

  • Variance: The average of the squared differences from the mean. It quantifies how much the data points deviate from the mean.

  • Standard Deviation: The square root of the variance. It provides a more interpretable measure of spread in the same units as the data.

  • Interquartile Range (IQR): The range within the middle 50% of the data (between the first and third quartiles). It’s a robust measure of spread that isn’t affected by outliers.

Code
# Adjust the layout and margins
par(mfrow = c(8, 9), mar = c(1, 1, 2.5, 1))

for (col in colnames(data)) {
  plot(density(data[[col]]), 
       main = col,
       xlab = col, col = "#009AEF", lwd = 2)
}
Figure 2: Data distribution before quantile normalization
Code
data %>% 
  select_if(is.numeric) %>%
  apply(2, function(x) round(summary(x), 3)) %>% 
  kbl() %>%
  kable_styling(bootstrap_options = c("striped", "bordered")) %>% 
  kable_classic() %>%
  scroll_box(width = "100%", height = "100%")
Exp1Wt_1 Exp1Wt_2 Exp1Wt_3 Exp2Wt_1 Exp2Wt_2 Exp2Wt_3 Exp2Wt_4 Exp3Wt_1 Exp3Wt_2 Exp3Wt_3 Exp1Tg_1 Exp1Tg_2 Exp1Tg_3 Exp2Tg_1 Exp2Tg_2 Exp2Tg_3 Exp2Tg_4 Exp3Tg_1 Exp3Tg_2 Exp3Tg_3 Exp4Tg_1 Exp4Tg_2 Exp4Tg_3 Exp1Rem3_1 Exp1Rem3_2 Exp1Rem3_3 Exp1Rem6_1 Exp1Rem6_2 Exp1Rem6_3 Exp2Rem6_1 Exp2Rem6_2 Exp2Rem6_3 Exp2Rem6_4 Exp3Rem6_1 Exp3Rem6_2 Exp3Rem6_3 Exp2Hum6_1 Exp2Hum6_2 Exp2Hum6_3 Exp2Hum6_4 Exp3Hum6_1 Exp3Hum6_2 Exp3Hum6_3 Exp4Hum6_1 Exp4Hum6_2 Exp4Hum6_3 Exp2Enb6_1 Exp2Enb6_2 Exp2Enb6_3 Exp2Enb6_4 Exp4Enb6_1 Exp4Enb6_2 Exp4Enb6_3 Exp4Enb6_4 Exp4Enb6_5 Exp4Enb6_6 Exp2Cim6_1 Exp2Cim6_2 Exp2Cim6_3 Exp2Cim6_4 Exp4Cim6_1 Exp4Cim6_2 Exp4Cim6_3 Exp4Cim6_4 Exp4Cim6_5 Exp4Cim6_6
Min. 3.376 3.144 3.338 3.726 3.615 3.586 3.555 1.029 0.978 0.806 3.349 3.261 3.282 3.607 3.728 3.754 3.605 0.751 1.088 1.023 1.177 1.101 1.058 3.407 3.372 3.283 3.390 3.329 3.305 3.682 3.624 3.589 3.662 0.978 1.015 1.059 3.626 3.578 3.658 3.689 1.100 0.953 1.021 1.084 1.144 1.114 3.733 3.609 3.716 3.787 1.210 1.096 1.147 1.376 1.283 1.318 3.632 3.676 3.691 3.685 1.233 1.147 1.014 1.377 1.201 1.128
1st Qu. 4.550 4.524 4.441 5.039 4.981 4.993 5.038 5.169 5.199 5.276 4.596 4.719 4.808 4.973 4.938 4.987 5.027 5.155 5.186 5.172 4.358 4.395 4.352 4.565 4.675 4.493 4.525 4.500 4.705 4.952 4.956 4.982 5.004 5.269 5.199 5.177 4.976 4.975 4.952 4.968 5.170 5.201 5.208 4.376 4.365 4.368 5.027 5.018 4.979 4.960 4.366 4.379 4.305 4.365 4.314 4.378 4.973 4.994 4.962 4.976 4.323 4.316 4.282 4.319 4.344 4.301
Median 6.030 6.070 6.107 6.790 6.841 6.833 6.752 6.727 6.706 6.665 6.042 5.997 6.029 6.831 6.840 6.852 6.781 6.734 6.730 6.745 5.806 5.761 5.783 6.126 6.066 6.057 6.040 6.026 6.016 6.813 6.812 6.810 6.849 6.691 6.757 6.714 6.837 6.804 6.827 6.839 6.744 6.726 6.708 5.806 5.805 5.789 6.811 6.808 6.825 6.864 5.765 5.780 5.798 5.773 5.778 5.792 6.834 6.798 6.847 6.815 5.786 5.805 5.799 5.788 5.806 5.762
Mean 6.260 6.285 6.286 6.960 6.952 6.944 6.934 6.623 6.619 6.616 6.270 6.221 6.233 6.966 6.952 6.981 6.943 6.616 6.624 6.626 5.743 5.726 5.730 6.341 6.296 6.266 6.265 6.240 6.245 6.948 6.952 6.952 6.952 6.624 6.637 6.623 6.958 6.958 6.953 6.969 6.624 6.635 6.630 5.756 5.737 5.732 6.957 6.960 6.950 6.972 5.730 5.750 5.738 5.736 5.732 5.744 6.953 6.942 6.957 6.952 5.738 5.740 5.731 5.740 5.747 5.728
3rd Qu. 7.679 7.745 7.797 8.523 8.536 8.526 8.487 8.123 8.092 8.028 7.649 7.452 7.389 8.601 8.594 8.599 8.522 8.147 8.126 8.138 7.113 7.046 7.091 7.826 7.637 7.727 7.704 7.679 7.513 8.556 8.576 8.538 8.524 8.056 8.135 8.133 8.560 8.570 8.568 8.581 8.127 8.131 8.109 7.134 7.091 7.101 8.525 8.532 8.542 8.612 7.068 7.099 7.134 7.094 7.120 7.099 8.555 8.523 8.573 8.558 7.133 7.147 7.140 7.137 7.126 7.129
Max. 13.482 13.700 13.650 13.684 13.776 13.726 13.653 12.926 12.912 12.887 13.204 13.218 13.116 13.725 13.781 13.700 13.700 13.081 12.927 13.040 12.801 12.838 13.148 13.711 13.501 13.562 13.473 13.644 13.453 13.711 13.700 13.694 13.726 12.937 13.001 12.999 13.694 13.699 13.718 13.704 13.073 12.970 12.947 12.823 12.837 12.995 13.695 13.696 13.734 13.767 12.731 12.831 12.784 12.752 12.816 12.797 13.712 13.791 13.753 13.733 12.815 12.854 12.995 12.851 12.833 12.759
Code
calculate_metrics = function(data.frame) {
  max <- apply(data.frame, 2, max)
  min <- apply(data.frame, 2, min)
  mean <- (max + min) / 2

  dt_matrix = data.frame(name = colnames(data.frame),
                         min = as.numeric(as.character(min)),
                         max = as.numeric(as.character(max)),
                         mean = as.numeric(as.character(mean)))
  return(dt_matrix)
}

# Calculate metrics for each condition
c_metrics = calculate_metrics(data)
c_metrics
         name     min     max     mean
1    Exp1Wt_1 3.37556 13.4822 8.428880
2    Exp1Wt_2 3.14427 13.7005 8.422385
3    Exp1Wt_3 3.33822 13.6498 8.494010
4    Exp2Wt_1 3.72646 13.6836 8.705030
5    Exp2Wt_2 3.61474 13.7756 8.695170
6    Exp2Wt_3 3.58591 13.7262 8.656055
7    Exp2Wt_4 3.55539 13.6532 8.604295
8    Exp3Wt_1 1.02914 12.9258 6.977470
9    Exp3Wt_2 0.97795 12.9121 6.945025
10   Exp3Wt_3 0.80624 12.8875 6.846870
11   Exp1Tg_1 3.34917 13.2042 8.276685
12   Exp1Tg_2 3.26118 13.2179 8.239540
13   Exp1Tg_3 3.28197 13.1161 8.199035
14   Exp2Tg_1 3.60711 13.7250 8.666055
15   Exp2Tg_2 3.72809 13.7809 8.754495
16   Exp2Tg_3 3.75376 13.6998 8.726780
17   Exp2Tg_4 3.60466 13.6999 8.652280
18   Exp3Tg_1 0.75115 13.0814 6.916275
19   Exp3Tg_2 1.08764 12.9265 7.007070
20   Exp3Tg_3 1.02303 13.0399 7.031465
21   Exp4Tg_1 1.17688 12.8012 6.989040
22   Exp4Tg_2 1.10078 12.8384 6.969590
23   Exp4Tg_3 1.05794 13.1482 7.103070
24 Exp1Rem3_1 3.40727 13.7114 8.559335
25 Exp1Rem3_2 3.37224 13.5005 8.436370
26 Exp1Rem3_3 3.28277 13.5621 8.422435
27 Exp1Rem6_1 3.38981 13.4728 8.431305
28 Exp1Rem6_2 3.32883 13.6436 8.486215
29 Exp1Rem6_3 3.30500 13.4533 8.379150
30 Exp2Rem6_1 3.68185 13.7110 8.696425
31 Exp2Rem6_2 3.62371 13.7001 8.661905
32 Exp2Rem6_3 3.58858 13.6942 8.641390
33 Exp2Rem6_4 3.66171 13.7255 8.693605
34 Exp3Rem6_1 0.97805 12.9367 6.957375
35 Exp3Rem6_2 1.01526 13.0005 7.007880
36 Exp3Rem6_3 1.05879 12.9986 7.028695
37 Exp2Hum6_1 3.62648 13.6944 8.660440
38 Exp2Hum6_2 3.57819 13.6989 8.638545
39 Exp2Hum6_3 3.65832 13.7184 8.688360
40 Exp2Hum6_4 3.68866 13.7042 8.696430
41 Exp3Hum6_1 1.09956 13.0734 7.086480
42 Exp3Hum6_2 0.95331 12.9700 6.961655
43 Exp3Hum6_3 1.02125 12.9465 6.983875
44 Exp4Hum6_1 1.08401 12.8233 6.953655
45 Exp4Hum6_2 1.14380 12.8366 6.990200
46 Exp4Hum6_3 1.11394 12.9948 7.054370
47 Exp2Enb6_1 3.73300 13.6948 8.713900
48 Exp2Enb6_2 3.60938 13.6959 8.652640
49 Exp2Enb6_3 3.71600 13.7344 8.725200
50 Exp2Enb6_4 3.78704 13.7671 8.777070
51 Exp4Enb6_1 1.21022 12.7314 6.970810
52 Exp4Enb6_2 1.09627 12.8306 6.963435
53 Exp4Enb6_3 1.14697 12.7839 6.965435
54 Exp4Enb6_4 1.37550 12.7517 7.063600
55 Exp4Enb6_5 1.28300 12.8161 7.049550
56 Exp4Enb6_6 1.31791 12.7969 7.057405
57 Exp2Cim6_1 3.63227 13.7120 8.672135
58 Exp2Cim6_2 3.67638 13.7910 8.733690
59 Exp2Cim6_3 3.69146 13.7532 8.722330
60 Exp2Cim6_4 3.68540 13.7332 8.709300
61 Exp4Cim6_1 1.23322 12.8151 7.024160
62 Exp4Cim6_2 1.14684 12.8535 7.000170
63 Exp4Cim6_3 1.01430 12.9947 7.004500
64 Exp4Cim6_4 1.37744 12.8509 7.114170
65 Exp4Cim6_5 1.20130 12.8331 7.017200
66 Exp4Cim6_6 1.12756 12.7590 6.943280

5 Data Normalization

The primary goal of quantile normalization is to align the statistical distributions of all samples so that they are the same. This technique assumes that all samples should have the same overall distribution of values (e.g., gene expression levels), meaning that any differences between samples that aren’t due to biological variation are artifacts that need to be corrected.

Steps of Quantile Normalization

  • Sort the Data:

    For each sample (e.g., each column in a matrix of gene expression data), the data is sorted / ranked in ascending order.

  • Average the Sorted Values:

    Across all samples, for each rank, the values are averaged. This creates a “reference” distribution, where each rank corresponds to the average value of that rank across all samples.

  • Replace Original Values:

    Each value in the original dataset is replaced by the corresponding value from the reference distribution.

  • Output the Normalized Data:

    The result is a new dataset where each sample has the same distribution of values, which helps remove any technical variations between samples.

Code
# Convert dataframe to matrix
data = as.matrix(data)

# Normalize data
data = normalize.quantiles(data , copy=TRUE)

# Convert matrix to dataframe
data = data.frame(data)

# Add column names to dataframe
colnames(data) = Sample

# Add row names to dataframe
rownames(data) = Gene
Code
boxplot(data, horizontal = T, las = 1, cex.axis = 0.5)
Figure 3: Boxplot of data after quantile normalization
Code
# Adjust the layout and margins 
par(mfrow = c(8, 9), mar = c(1, 1, 2.5, 1))

for (col in colnames(data)) {
  plot(density(data[[col]]), 
       main = col,
       xlab = col, col = "#009AEF", lwd = 2)
}
Figure 4: Data distribution after quantile normalization

6 Dimension Reduction Algorithms

6.1 Uniform Manifold Approximation and Projection (UMAP)

UMAP (Uniform Manifold Approximation and Projection) is a dimensionality reduction algorithm that is widely used in data science and machine learning. It is designed to help visualize high-dimensional data in a lower-dimensional space, typically 2D or 3D, while preserving the global and local structure of the data as much as possible.

Key concepts of UMAP

  1. Manifold Learning: UMAP is based on the idea that high-dimensional data often lies on a lower-dimensional manifold, a geometry concept. UMAP aims to learn this manifold and then project the data onto a lower-dimensional space that best represents the structure of the data.

  2. Topology: UMAP uses topological techniques to understand the shape of the data. It constructs a graph that represents the relationships between data points based on their proximity. This graph is then used to project the data into a lower-dimensional space.

  3. Optimization: The final embedding is obtained by optimizing a cost function that balances the preservation of local structures (how points are grouped) and global structures (the overall layout).

Applications

  1. Visualization: UMAP is often used to visualize complex datasets, such as in biology (e.g., gene expression data), where it helps to identify patterns and clusters.

  2. Preprocessing: It can be used as a preprocessing step before other machine learning algorithms, such as clustering or classification, to reduce dimensionality while maintaining the integrity of the data structure.

  3. Data Exploration: UMAP is useful for exploring and understanding large datasets, making it easier to identify trends, outliers, and relationships within the data.

Comparison to other techniques

  • t-SNE: UMAP is similar to t-SNE, another popular dimensionality reduction technique. However, UMAP is generally faster and better at preserving both global and local structures, making it more effective for large datasets.

  • PCA (Principal Component Analysis): PCA is another common method for dimensionality reduction but focuses on preserving linear relationships, which may not capture the complexity of data as effectively as UMAP, especially in cases of non-linear structures.

Code
# Keep only WT and TG samples
wt_tg_df = data[, 1:23]

# After dataframe transposition columns must represent genes
wt_tg_df = t(wt_tg_df)
Code
# UMAP dimension reduction for wt and tg samples
wt_tg_df.umap <- umap(wt_tg_df, n_components=2, random_state=15)

# Keep the numeric dimensions
wt_tg_df.umap <- wt_tg_df.umap[["layout"]]

# Create vector with groups
group = c(rep("A_Wt", 10), rep("B_Tg", 13))

# Create final dataframe with dimensions and group for plotting
wt_tg_df.umap <- cbind(wt_tg_df.umap, group)
wt_tg_df.umap <- data.frame(wt_tg_df.umap)

# Plot UMAP results
ggplotly(
  ggplot(wt_tg_df.umap, aes(x = V1, y = V2, color = group)) +
    geom_point() +
    labs(
      x = "UMAP1",
      y = "UMAP2",
      title = "UMAP plot",
      subtitle = "A UMAP Visualization of WT and TG samples") +
    theme(
      axis.text.x = element_blank(),
      axis.text.y = element_blank(),
      axis.ticks = element_blank()
    )
)
Figure 5: UMAP plot

6.2 Principal Component Analysis (PCA)

Principal Component Analysis (PCA) is a statistical technique used to simplify complex datasets by reducing their dimensionality while preserving as much variance as possible. The main idea behind PCA is to transform the original data into a new coordinate system where the greatest variance in the data is captured in the first few dimensions (called principal components). Here’s how PCA works step-by-step:

Covariance Matrix Computation

  • Calculate the covariance matrix of the data. The covariance matrix is a square matrix that shows the covariance between different features. If there are \(n\) features, the covariance matrix will be of size \(n×n\). Covariance gives an idea of how much two features vary together.

Eigenvalue and Eigenvector Calculation

  • Compute the eigenvalues and eigenvectors of the covariance matrix.
  • Eigenvectors represent the directions of the new feature space, and eigenvalues tell us how much variance is along each of these directions.
  • The eigenvector with the highest eigenvalue is the first principal component, which captures the most variance in the data. The second principal component is orthogonal to the first and captures the second most variance, and so on.

Sort Eigenvectors

  • Sort the eigenvectors by their corresponding eigenvalues in descending order. This ordering helps in deciding which principal components to keep. The components corresponding to the largest eigenvalues capture the most significant structure in the data.

Dimensionality Reduction

  • Choose the top \(k\) eigenvectors (where \(k\) is the number of dimensions you want to reduce your data to) and project the original data onto these eigenvectors. This transformation gives you the data represented in terms of the principal components, reducing the dimensionality from \(n\) to \(k\).
  • The resulting \(k\)-dimensional space retains most of the variability in the original \(n\)-dimensional space.

Projection of data

  • Finally, the original data is transformed into the new feature space defined by the selected principal components. This projection is done by multiplying the original data matrix by the matrix of eigenvectors.

Applications

  • Data compression: Reducing the number of features while retaining most of the original information.

  • Noise reduction: By keeping the most significant components, noise in the data (which might be in less significant components) can be reduced.

  • Visualization: Reducing data to 2 or 3 dimensions makes it easier to visualize, especially in high-dimensional datasets.

  • Preprocessing: Used as a preprocessing step before applying machine learning algorithms to improve performance and reduce computational cost.

Code
# PCA dimension reduction
wt_tg_df.pca <- prcomp(wt_tg_df, scale. = FALSE)
summary(wt_tg_df.pca)
Importance of components:
                           PC1     PC2     PC3      PC4     PC5    PC6     PC7
Standard deviation     64.2329 34.1273 30.6454 20.32780 13.6953 8.9139 7.93867
Proportion of Variance  0.5608  0.1583  0.1277  0.05617  0.0255 0.0108 0.00857
Cumulative Proportion   0.5608  0.7191  0.8468  0.90298  0.9285 0.9393 0.94785
                           PC8     PC9    PC10    PC11    PC12    PC13    PC14
Standard deviation     6.80061 6.34603 6.13851 5.80207 5.57370 5.31339 5.10862
Proportion of Variance 0.00629 0.00547 0.00512 0.00458 0.00422 0.00384 0.00355
Cumulative Proportion  0.95413 0.95961 0.96473 0.96930 0.97353 0.97737 0.98091
                          PC15    PC16    PC17    PC18    PC19    PC20    PC21
Standard deviation     4.95260 4.73197 4.56130 4.14881 3.95569 3.74775 3.64909
Proportion of Variance 0.00333 0.00304 0.00283 0.00234 0.00213 0.00191 0.00181
Cumulative Proportion  0.98425 0.98729 0.99012 0.99246 0.99459 0.99649 0.99830
                         PC22      PC23
Standard deviation     3.5312 8.294e-14
Proportion of Variance 0.0017 0.000e+00
Cumulative Proportion  1.0000 1.000e+00
Code
plot_grid(fviz_pca_ind(wt_tg_df.pca, repel = TRUE, # Avoid text overlapping
                  habillage = group,
                  label = "none",
                  axes = c(1, 2), # choose PCs to plot
                  addEllipses = TRUE,
                  ellipse.level = 0.95,
                  title = "Biplot: PC1 vs PC2") +
                  scale_color_manual(values = c('#33cc00','#009AEF95')) +
                  scale_fill_manual(values = c('#33cc00','#009AEF95')),
          fviz_pca_ind(wt_tg_df.pca, repel = TRUE, # Avoid text overlapping
                  habillage = group,
                  label = "none",
                  axes = c(1, 3), # choose PCs to plot
                  addEllipses = TRUE,
                  ellipse.level = 0.95,
                  title = "Biplot: PC1 vs PC3") + 
                  scale_color_manual(values = c('#33cc00','#009AEF95')) +
                  scale_fill_manual(values = c('#33cc00','#009AEF95')),
          fviz_pca_ind(wt_tg_df.pca, repel = TRUE, # Avoid text overlapping
                  habillage = group,
                  label = "none",
                  axes = c(2, 3), # choose PCs to plot
                  addEllipses = TRUE,
                  ellipse.level = 0.95,
                  title = "Biplot: PC2 vs PC3") +
                  scale_color_manual(values = c('#33cc00','#009AEF95')) +
                  scale_fill_manual(values = c('#33cc00','#009AEF95')),
          
          # Visualize eigenvalues/variances
          fviz_screeplot(wt_tg_df.pca, 
                    addlabels = TRUE,
                    title = "Principal Components Contribution",
                    ylim = c(0, 65), 
                    barcolor = "#009AEF95",  
                    barfill = "#009AEF95"),
          
          # Contributions of features to PC1
          fviz_contrib(wt_tg_df.pca, 
                  choice = "var", 
                  axes = 1, 
                  top = 14, 
                  color = "#009AEF95", 
                  fill = "#009AEF95"),
          
          # Contributions of features to PC2
          fviz_contrib(wt_tg_df.pca, 
                  choice = "var", 
                  axes = 2, 
                  top = 14, 
                  color = "#009AEF95", 
                  fill = "#009AEF95"),
          labels = c("A", "B", "C", "D", "E", "F")
)
Figure 6: Plot PCA results
Code
wt_tg_df.pca <- data.frame("PC1" = wt_tg_df.pca$x[,1], 
                           "PC2" = wt_tg_df.pca$x[,2], 
                           "group" = group)

# Plot PCA results

# insert dataframe [1] , variables [2]-[3] and color groyp [4]
ggplotly(
  ggplot( wt_tg_df.pca, aes(x= PC1 , y= PC2 , color= group ))+
    
    # try "geom_point" or "geom_line"
    geom_point()+
    
    # try "ggtitle" or "ggname"
    ggtitle("Two First Components of PCA") +
    theme(axis.text.x = element_blank(),
          axis.text.y = element_blank(),
          axis.ticks = element_blank())
)
Figure 7: Plot two first components of PCA

7 Statistical Analysis

7.1 Group treatments in dataframe

ANOVA, or Analysis of Variance, is a statistical method used to compare means among three or more groups to determine if there are any statistically significant differences between them. It extends the t-test, which is typically used to compare the means of two groups, to situations where more than two groups are involved. ANOVA allows for the simultaneous assessment of variations within and between groups, enabling the identification of genes with expression patterns that are significantly different across experimental conditions. It is particularly useful in experiments where multiple groups or conditions are being tested simultaneously.

Hypotheses in ANOVA

ANOVA tests the following hypotheses:

  • Null Hypothesis (H₀): All group means are equal. (No significant difference between groups)

  • Alternative Hypothesis (H₁): At least one group mean is different from the others. (There is a significant difference between groups)

Partitioning Variance

ANOVA works by partitioning the total variance observed in the data into two components:

  1. Between-Group Variance: The variation due to the interaction between the different groups. This measures how much the group means differ from the overall mean.

  2. Within-Group Variance (Error Variance): The variation within each group. This measures how much individual observations differ from their group mean.

Mathematically, the total variance is expressed as:

$$ \text{Total Variance} = \text{Between-Group Variance} + \text{Within-Group Variance} $$

F-Ratio Calculation

ANOVA calculates an F-ratio by comparing the between-group variance to the within-group variance:

\[ F = \frac{\text{Between-Group Variance}}{\text{Within-Group Variance}} \]

  • A large F-ratio indicates that the between-group variance is large relative to the within-group variance, suggesting that the group means are significantly different.

  • A small F-ratio suggests that any observed differences in means are more likely due to random chance.

ANOVA table

The results of ANOVA are typically summarized in an ANOVA table, which includes:

  • Sum of Squares (SS): Measures of variation for both between-group and within-group components.

  • Degrees of Freedom (df): The number of values that are free to vary for each component.

  • Mean Squares (MS): Calculated by dividing the sum of squares by the corresponding degrees of freedom.

  • F-Statistic (F): The ratio of mean squares between groups to mean squares within groups.

Assumptions of ANOVA

For the results of ANOVA to be valid, several assumptions need to be met:

  1. Independence: The observations within each group and between groups should be independent of each other.

  2. Normality: The data in each group should be approximately normally distributed.

  3. Homogeneity of Variances: The variances among the groups should be approximately equal.

Code
# -------------------Apply ANOVA on all genes----------------------

# Create Matrix by Excluding rownames and colnames
matrixdata = as.matrix(data)

# Create Groups
group = factor(c(
  rep("A_Wt", 10),
  rep("B_Tg", 13),
  rep("C_Proph_Ther_Rem", 3),
  rep("D_Ther_Rem", 10),
  rep("E_Ther_Hum", 10),
  rep("F_Ther_Enb", 10),
  rep("G_Ther_Cim", 10)
))


# Create empty dataframe
anova_table = data.frame()

# Recursive parse all genes
for( i in 1:length( matrixdata[ , 1 ] ) ) {
  
  # Create dataframe for each gene
  df = data.frame("gene_expression" = matrixdata[ i , ], 
                  "group" = group)
  
  # Apply ANOVA for gene i
  gene_aov = aov( gene_expression ~ group , data = df)
  
  # Apply tukey's post-hoc test on ANOVA results
  tukey = TukeyHSD( gene_aov , conf.level = 0.99)
  
  # Vector calling Tukey's values
  tukey_data = c(tukey$group["B_Tg-A_Wt", 1],
                 tukey$group["B_Tg-A_Wt", 4],
                 tukey$group["C_Proph_Ther_Rem-A_Wt", 1],
                 tukey$group["C_Proph_Ther_Rem-A_Wt", 4],
                 tukey$group["D_Ther_Rem-A_Wt", 1],
                 tukey$group["D_Ther_Rem-A_Wt", 4],
                 tukey$group["E_Ther_Hum-A_Wt", 1],
                 tukey$group["E_Ther_Hum-A_Wt", 4],
                 tukey$group["F_Ther_Enb-A_Wt", 1],
                 tukey$group["F_Ther_Enb-A_Wt", 4],
                 tukey$group["G_Ther_Cim-A_Wt", 1],
                 tukey$group["G_Ther_Cim-A_Wt", 4],
                 
                 tukey$group["C_Proph_Ther_Rem-B_Tg", 1],
                 tukey$group["C_Proph_Ther_Rem-B_Tg", 4],
                 tukey$group["D_Ther_Rem-B_Tg", 1],
                 tukey$group["D_Ther_Rem-B_Tg", 4],
                 tukey$group["E_Ther_Hum-B_Tg", 1],
                 tukey$group["E_Ther_Hum-B_Tg", 4],
                 tukey$group["F_Ther_Enb-B_Tg", 1],
                 tukey$group["F_Ther_Enb-B_Tg", 4],
                 tukey$group["G_Ther_Cim-B_Tg", 1],
                 tukey$group["G_Ther_Cim-B_Tg", 4])
  
  # Append Tukey's data to dataframe
  anova_table = rbind( anova_table , tukey_data)
}

colnames(anova_table) <- c("Wt_Tg_diff", "Wt_Tg_padj",
                           "Wt_Rem_P_diff", "Wt_Rem_P_padj", 
                           "Wt_Rem_diff", "Wt_Rem_padj", 
                           "Wt_Hum_diff", "Wt_Hum_padj", 
                           "Wt_Enb_diff", "Wt_Enb_padj", 
                           "Wt_Cim_diff", "Wt_Cim_padj",
                           
                           "Tg_Rem_P_diff", "Tg_Rem_P_padj", 
                           "Tg_Rem_diff", "Tg_Rem_padj", 
                           "Tg_Hum_diff", "Tg_Hum_padj", 
                           "Tg_Enb_diff", "Tg_Enb_padj", 
                           "Tg_Cim_diff", "Tg_Cim_padj")

# Add rownames with gene names
rownames(anova_table) = Gene

8 Volcano Plot

Code
# -----------------Volcano plot preparation---------------------

# Create variables for upregulated/downregulated genes and genes with no observed change in expression levels
upWT = 0
downWT = 0
nochangeWT = 0

# Filter Differential Expressed Genes
upWT = which(anova_table[ , 1 ] < -1.0 & anova_table[ , 2 ] < 0.05)

downWT = which(anova_table[ , 1 ] > 1.0 & anova_table[ , 2 ] < 0.05)

nochangeWT = which(anova_table[ , 2 ] > 0.05 | 
                  (anova_table[ , 1 ] > -1.0 & anova_table[ , 1 ] < 1.0 ) )

# Create vector to store states for each gene
state <- vector(mode="character", length=length(anova_table[,1]))
state[upWT]   <- "up_WT"
state[downWT] <- "down_WT"
state[nochangeWT] <- "nochange_WT"

# Identify names of genes differentially expressed between wt and tg
genes_up_WT   <- c(rownames(anova_table)[upWT])
genes_down_WT <- c(rownames(anova_table)[downWT])

# Union of DEGs between wt and tg
deg_wt_tg <- c(genes_up_WT, genes_down_WT)

# Subset dataframe based on specific degs
deg_wt_tg_df <- subset(data , Gene %in% deg_wt_tg)

## Dataframe for volcano plot
volcano_data <- data.frame("padj" = anova_table[,2], 
                           "DisWt" = anova_table[,1], 
                           state=state)
Code
ggplot(volcano_data , aes(x = DisWt , y = -log10(padj) , colour = state )) +
    
    geom_point() +
    
    labs(x = "mean(Difference)",
         y = "-log10(p-value)",
         title = "Volcano Plot",
         subtitle = "Differentially Expressed Genes (WT vs TG)") +
    
    # Insert line to show cutoff
    geom_vline(xintercept = c( -1 , 1 ),
               linetype = "dashed",
               color = "black") +
    
    # insert line to show cutoff
    geom_hline(yintercept = -log10(0.05),
               linetype = "dashed",
               color = "black")
Figure 8: Volcano plot of differentially expressed genes

8.1 Notes on Volcano Plot Interpretation

A volcano plot is a type of scatter plot commonly used in high-throughput data analysis, particularly in genomics, proteomics, and transcriptomics. It’s particularly useful for visualizing the results of differential expression analyses, where you’re comparing two conditions to identify genes, proteins, or other features that are significantly differentially expressed.

Structure

  • X-axis (mean(Difference)): This represents the magnitude of change between two conditions. A mean change of 0 indicates no change, positive values indicate upregulation (more abundant in the condition being tested), and negative values indicate downregulation (less abundant).

  • Y-axis (−log10(p-value)): This axis represents the statistical significance of the observed changes, often using a p-value from a statistical test. The higher the value on this axis, the more significant the change. Since it is a negative log scale, higher values represent smaller p-values.

Interpretation

  • Significance: Points located at the top of the plot have high statistical significance. The further a point is from the origin along the y-axis, the more significant the result.

  • Magnitude: Points farther to the right (positive mean change) indicate genes/proteins/features that are upregulated, while points farther to the left (negative mean change) indicate downregulation.

  • Significant Features: Typically, the most interesting features are those that are both statistically significant (high on the y-axis) and have a large magnitude of change (far left or far right on the x-axis). These appear as points in the upper left or upper right corners of the plot.

  • Thresholds: Horizontal and vertical lines are often added to represent thresholds for significance. Points outside these thresholds are often colored differently to highlight significant changes.

9 Uniform Manifold Approximation and Projection (UMAP) after identifying Differentially Expresssed Genes

Code
# Subset dataframe based on specific degs
deg_wt_tg_df = subset(data , Gene %in% deg_wt_tg)

deg_wt_tg_df = deg_wt_tg_df[,1:23]

# After dataframe transposition columns must represent genes
deg_wt_tg_df = t(deg_wt_tg_df)
Code
# UMAP dimension reduction for wt and tg samples
deg_wt_tg_df.umap = umap(deg_wt_tg_df, n_components=2, random_state=15)

# Keep the numeric dimensions
deg_wt_tg_df.umap = deg_wt_tg_df.umap[["layout"]]

# Create vector with groups
group = c(rep("A_Wt", 10), rep("B_Tg", 13) )

# Create final dataframe with dimensions and group for plotting
deg_wt_tg_df.umap = cbind(deg_wt_tg_df.umap, group)
deg_wt_tg_df.umap = data.frame(deg_wt_tg_df.umap)

# Plot UMAP results
ggplotly(
  ggplot(deg_wt_tg_df.umap, aes(x = V1, y = V2, color = group)) +
    geom_point() +
    labs(x = "UMAP1", y = "UMAP2", 
         title = "UMAP plot", 
         subtitle = "A UMAP Visualization of WT and TG samples (DEGs subset)") +
    theme(axis.text.x = element_blank(),
          axis.text.y = element_blank(),
          axis.ticks = element_blank())
  )
Figure 9: UMAP plot of differentially expressed genes
Code
# Group wt and tg as character and not factor
group = c(rep("A_Wt", 10), rep("B_Tg", 13) )

# Dimension reduction with PCA for wt and tg dataframe
deg_wt_tg_df.pca = prcomp(deg_wt_tg_df , scale. = FALSE)

deg_wt_tg_df.pca = data.frame("PC1" = deg_wt_tg_df.pca$x[,1] , 
                              "PC2" = deg_wt_tg_df.pca$x[,2] , 
                              "group" = group)

# Plot PCA results
ggplotly(
  ggplot(deg_wt_tg_df.pca , aes(x=PC1,y=PC2,color=group))+
    geom_point()+
    labs(x = "PC1", y = "PC2", 
         title = "PCA plot", 
         subtitle = "A PCA Visualization of WT and TG samples (DEGs subset)") +
    theme(axis.text.x = element_blank(),
          axis.text.y = element_blank(),
          axis.ticks = element_blank())
)
Figure 10: PCA plot of differentially expresssed genes

9.0.1 Identify differentially expressed genes between transgenic animals and at least one therapy

Code
# Volcano plot dataframe preparation for DEGs from TG vs therapies
upTHER = 0
downTHER = 0
nochangeTHER = 0

# Filter genes based on mean diff and p_value between TG and therapies
upTHER = which((anova_table[,13] < -1.0 & anova_table[,14] < 0.05) | 
               (anova_table[,15] < -1.0 & anova_table[,16] < 0.05) | 
               (anova_table[,17] < -1.0 & anova_table[,18] < 0.05) |
               (anova_table[,19] < -1.0 & anova_table[,20] < 0.05) |
               (anova_table[,21] < -1.0 & anova_table[,22] < 0.05) )

downTHER = which((anova_table[,13] > 1.0 & anova_table[,14] < 0.05) | 
                 (anova_table[,15] > 1.0 & anova_table[,16] < 0.05) | 
                 (anova_table[,17] > 1.0 & anova_table[,18] < 0.05) |
                 (anova_table[,19] > 1.0 & anova_table[,20] < 0.05) |
                 (anova_table[,21] > 1.0 & anova_table[,22] < 0.05) )

nochangeTHER = which( ( (anova_table[,13] > -1.0 & anova_table[,13] < 1.0) |   
                         anova_table[,14] > 0.05) |
                  
                      ( (anova_table[,15] > -1.0 & anova_table[,15] < 1.0) |
                         anova_table[,16] > 0.05) |
                        
                      ( (anova_table[,17] > -1.0 & anova_table[,17] < 1.0) |
                         anova_table[,18] > 0.05) |
                        
                      ( (anova_table[,19] > -1.0 & anova_table[,19] < 1.0) |
                         anova_table[,20] > 0.05) |
                        
                      ( (anova_table[,21] > -1.0 & anova_table[,21] < 1.0) |
                         anova_table[,22] > 0.05) )

# Create vector to store states for each gene
state = vector(mode = "character", length = length(anova_table[,1]))
state[upTHER] = "up_THER"
state[downTHER] = "down_THER"
state[nochangeTHER] = "nochange_THER"

# Identify names of genes differentially expressed between TG and therapies
genes_up_THER = c(rownames(anova_table)[upTHER])
genes_down_THER = c(rownames(anova_table)[downTHER])

deg_tg_ther = c(genes_up_THER, genes_down_THER)

# Combine DEGs from TG and THER
DEGs = c(deg_tg_ther, deg_wt_tg)

# Data frame with all DEGs for clustering
DEGsFrame = anova_table[rownames(anova_table) %in% DEGs, ]
DEGsFrame = as.matrix(DEGsFrame)

10 Hierarchical clustering

Code
# k-means clustering
# ------------------
kmeans = kmeans(DEGsFrame[, c(1,3,5,7,9,11) ], centers = 6)
ggplotly(fviz_cluster(kmeans, data = (DEGsFrame[, c(1,3,5,7,9,11)]), geom = "point", show.clust.cent = TRUE))
Figure 11: Clusters of differentially expressed genes
Code
# Extract genes from clusters
clusters = data.frame(kmeans$cluster)
colnames(clusters) = ("ClusterNo")

# Output data as table (group by cluster number)
kable(clusters, col.names = "Cluster Number", caption = "Clusters and associated genes") |>
        kable_styling(font_size = 14) |>
        scroll_box(height = "400px")
Clusters and associated genes
Cluster Number
Abca5 1
Abca6 1
Abca8a 1
Abca8b 1
Abcb4 4
Abhd14b 5
Ablim1 1
Abra 2
Acaca 1
Acacb 4
Acan 1
Ache 2
Acp2 3
Acp5 6
Acpp 6
Acsl6 4
Acss3 1
Acta1 2
Actc1 1
Actg2 5
Actn2 2
Actn3 2
Acvr1c 1
Acvr2a 5
Acyp2 2
Adam8 6
Adamts13 3
Adamts15 3
Adamts4 6
Adamts5 1
Adamts7 3
Adcy5 5
Adig 1
Adipoq 1
Adk 1
Adprhl1 2
Adrbk2 6
Aff2 4
Agbl1 2
Agpat9 5
Aif1 3
Aim1 6
Akna 3
Akt2 1
Alas2 4
Alcam 6
Aldh1a1 1
Aldh1a3 1
Aldh1a7 1
Aldh3a1 5
Aldh6a1 1
Aldob 3
Aldoc 3
Alg3 3
Alox12 1
Alpk3 2
Amacr 3
Amot 2
Ampd1 2
Amy1 1
Angptl4 3
Angptl7 1
Ank2 5
Ank3 2
Ankrd1 2
Ankrd2 4
Ankrd23 2
Ankrd55 3
Ano5 4
Anpep 3
Anxa8 5
Aoah 6
Aox1 1
Aox3 5
Ap4s1 1
Apbb1ip 3
Apobec1 6
Apobec2 4
Apobec3 3
Aprt 3
Aqp7 1
Ar 2
Arg1 6
Arg2 3
Arhgap19 1
Arhgap20 4
Arhgap28 5
Arhgap30 6
Arhgap4 3
Arhgef10 5
Arhgef9 1
Arid3c 3
Arpc1b 3
Arpc2 3
Arpc3 3
Arrdc4 3
Art3 4
Asb11 2
Asb12 4
Asb14 4
Asb15 2
Asb2 2
Asb5 2
Asf1b 3
Aspa 4
Aspm 3
Asrgl1 5
Atf3 3
Atn1 3
Atp1a2 4
Atp1a3 3
Atp1b1 2
Atp1b2 2
Atp1b4 2
Atp2a1 1
Atp6v0a4 1
Atp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
Xkr7 3
Xpr1 3
Yipf7 2
Zadh2 5
Zbp1 6
Zbtb10 5
Zbtb16 2
Zbtb41 5
Zc3h12a 3
Zfp106 1
Zfp212 5
Zfp330 5
Zfp36 3
Zfp365 5
Zfp36l2 3
Zfp385b 1
Zfp511 3
Zfp628 3
Zfp800 3
Zfp870 5
Zfpm2 3
Zfyve9 5
Zmiz2 3
Zmynd15 6
Zmynd17 4
Znhit6 5
Code
# Extract clusters
cluster1 = rownames(subset(clusters, ClusterNo == 1))
cluster2 = rownames(subset(clusters, ClusterNo == 2))
cluster3 = rownames(subset(clusters, ClusterNo == 3))
cluster4 = rownames(subset(clusters, ClusterNo == 4))
cluster5 = rownames(subset(clusters, ClusterNo == 5))
cluster6 = rownames(subset(clusters, ClusterNo == 6))
Code
# ---------------------Prepare data for heatmap-------------------------

# Define custom function to perform hierarchical clustering with the Ward.D2 linkage method
hclustfunc = function(x)
  hclust(x, method = "ward.D2")

# Define custom function to calculate pairwise Euclidean distances between data points
distfunc = function(x)
  dist(x, method = "euclidean")

# Perform clustering on rows and columns 
cl.row = hclustfunc(distfunc(DEGsFrame[, c(1,3,5,7,9,11)]))

# Extract cluster assignments of rows
gr.row = cutree(cl.row, k=6)

# Apply a set of color palette
colors = brewer.pal(5, "Set3")

heatmap <- heatmap.2(
          DEGsFrame[, c(1,3,5,7,9,11)],
          col = bluered(100), # blue-red color palette
          tracecol="black",
          density.info = "none",
          labCol = c("TG", "REM_P", "REM", "HUM", "ENB","CIM"),
          scale="none", 
          labRow="", 
          vline = 0,
          mar=c(6,2),
          RowSideColors = colors[gr.row],
          hclustfun = function(x) hclust(x, method = 'ward.D2')
)
Figure 12: Heatmap of differentially expressed genes after hierarchical clustering

10.1 Notes on Heatmap Interpretation

Rows: Each row represents a gene and the genes are clustered hierarchically (dendrogram on the left). Genes with similar expression patterns are grouped together.

Columns: They represent experimental conditions/ sample types.

Color Gradient (Color Key):

  • Red represents upregulated genes (positive values).

  • Blue represents downregulated genes (negative values).

  • The scale ranges from -4 to +4, indicating the intensity of differential expression (e.g. mean change).

Clustering:

  • The dendrogram on the top shows how the conditions are related based on the gene expression patterns. Conditions that cluster closer together (e.g., REM and TG) are likely to have similar expression profiles.

  • The dendrogram on the left shows how genes are grouped based on similarity in expression across the conditions.

Key Differences of Hierarchical vs K-means Clustering
Aspect Hierarchical Clustering K-means Clustering
Approach Builds hierarchy (Dendrogram) Partitions into flat clusters
Number of Clusters Determined post-analysis Must be predefined
Cluster Shape Can handle various shapes Assumes spherical clusters
Distance Metric

Multiple metrics

(e.g. Euclidean, Manhattan)

Only Euclidean distance
Scalability Not scalable for large datasets Efficient and scalable
Visual Output Dendrogram Cluster assignment
Handling Outliers Sensitive to outliers Sensitive, but manageable

Performing k-means clustering followed by creating a heatmap with hierarchical clustering combines the strengths of both clustering methods to get a more insightful and comprehensive visualization of the data. This hybrid approach can be particularly useful when working with large and complex datasets, such as gene expression data. This combination leverages the strengths of both methods: k-means for global structure and hierarchical clustering for local, detailed exploration.

11 Functional Enrichment Analysis of Differentially Expressed Genes (DEGs)

Once DEGs are identified, they need to be annotated to determine their biological functions, cellular localization, molecular interactions, and involvement in various biological pathways. This is often achieved by comparing DEGs to databases of known gene annotations, such as Gene Ontology (GO) or Kyoto Encyclopedia of Genes and Genomes (KEGG).

Pathway analysis focuses on identifying interconnected networks of genes that collaborate to carry out specific biological functions or participate in common signaling pathways. This involves mapping DEGs onto existing biological pathways and identifying key regulatory nodes or hub genes within these pathways. Pathway analysis provides insights into the underlying molecular mechanisms driving the observed gene expression changes.

The code below performs hierarchical clustering analysis on a gene expression dataset and then further analyzes the clusters to identify enriched biological terms using the databases: Gene Ontology (GO), with three Sub-Ontologies (Biological Process (BP), Cellular Component (CC), Molecular Function (MF)) transcription factors (TF), and Kyoto Encyclopedia of Genes and Genomes (KEGG) databases.

Code
# Get the cluster assignments
mt <- as.hclust(heatmap$rowDendrogram)

# Cut the tree into 8 clusters
tgcluster <- cutree(mt, k = 8)
tgdegnames <- rownames(DEGsFrame)

# Keep unique cluster numbers
cl <- as.numeric(names(table(tgcluster)))

totalresults <- 0
totalcols <- 0
pcols<-c("firebrick4", "red", "dark orange", "gold","dark green", "dodgerblue", "blue", "magenta", "darkorchid4")

# Iterating through clusters for functional enrichment 
#  The gost() function queries the significant genes from each cluster against various biological databases
for (i in c(6, 5, 4, 3, 2, 7, 1)) {
  gobp <- gost(query = as.character(tgdegnames[which(tgcluster == cl[i])]), organism = "mmusculus", significant = T, sources = "GO:BP")$result
  gomf <- gost(query = as.character(tgdegnames[which(tgcluster == cl[i])]), organism = "mmusculus", significant = T, sources = "GO:MF")$result
  gocc <- gost(query = as.character(tgdegnames[which(tgcluster == cl[i])]), organism = "mmusculus", significant = T, sources = "GO:CC")$result
  tf   <- gost(query = as.character(tgdegnames[which(tgcluster == cl[i])]), organism = "mmusculus", significant = T, sources = "TF")$result
  kegg <- gost(query = as.character(tgdegnames[which(tgcluster == cl[i])]), organism = "mmusculus", significant = T, sources = "KEGG")$result
  
  # Combine results
  results <- rbind(kegg, tf, gobp, gomf, gocc)
  
  # Filter the results based on different sources
  tf  <- grep("TF:", results$term_id)
  go  <- grep("GO:", results$term_id)
  kegg<-grep("KEGG:", results$term_id)
  
  # Get enriched terms/pathways, their associated p-values, and other relevant information obtained from the enrichment analysis.
  kegg<- results[kegg, ]
  tf  <- results[tf, ]
  go  <- results[go, ]

  # Order the results based on p-values
  kegg<- kegg[order(kegg$p_value), ]
  go  <- go[order(go$p_value), ]
  tf  <- tf[order(tf$p_value), ]
  
  # Split the term_id and term_name
  ll <- strsplit(as.character(tf$term_name), ": ")
  ll <- sapply(ll, "[[", 2)
  ll <- strsplit(as.character(ll), ";")
  tf$term_name <- sapply(ll, "[[", 1)
  
  # Remove duplicates
  if (length(tf$term_id) > 0) {
    uniqtf <- unique(tf$term_name)
    tfout <- 0
    for (ik in 1:length(uniqtf)) {
      nn <- which(as.character(tf$term_name) == as.character(uniqtf[ik]))
      tfn <- tf[nn, ]
      inn <- which(tfn$p_value == min(tfn$p_value))
      tfout <- rbind(tfout, head(tfn[inn, ], 1))
    }
    tf <- tfout[2:length(tfout[, 1]), ]
  }
  
  results <- rbind(head(kegg, 10), head(go, 10), head(tf, 10))
  totalresults <- rbind(totalresults, results)
  n <- length(results$term_id)
  totalcols <- c(totalcols, rep(pcols[i], n))
}

totalresults <- totalresults[2:length(totalresults[, 1]), ]
totalcols <- totalcols[2:length(totalcols)]
Code
# Custom layout/margins
par(mar = c(5, 15, 1, 2))

# Visualization of under-expressed clusters of DEGs
barplot(
  rev(-log10(totalresults$p_value[75:126])),
  xlab = "-log10(p-value)",
  ylab = "",
  cex.main = 1.3,
  cex.lab = 0.9,
  cex.axis = 0.9,
  main = "Under-Expressed Clusters",
  col = rev(totalcols[75:126]),
  horiz = T,
  names = rev(totalresults$term_name[75:126]),
  las = 1,
  cex.names = 0.6
)
Figure 13: Under-expressed clusters of differentially expressed genes after functional enrichment analysis
Code
# Custom layout/margins
par(mar = c(5, 15, 1, 2))

# Visualization of over-expressed clusters of DEGs
barplot(
  rev(-log10(totalresults$p_value[1:74])),
  xlab = "-log10(p-value)",
  ylab = "",
  cex.main = 1.3,
  cex.lab = 0.9,
  cex.axis = 0.9,
  main = "Over-Expressed Clusters",
  col = rev(totalcols[1:74]),
  horiz = T,
  names = rev(totalresults$term_name[1:74]),
  las = 1,
  cex.names = 0.6
)

References

Karagianni, Niki, Ksanthi Kranidioti, Nikolaos Fikas, Maria Tsochatzidou, Panagiotis Chouvardas, Maria C. Denis, George Kollias, and Christoforos Nikolaou. 2019. “An Integrative Transcriptome Analysis Framework for Drug Efficacy and Similarity Reveals Drug-Specific Signatures of Anti-TNF Treatment in a Mouse Model of Inflammatory Polyarthritis.” Edited by Cinzia Cantacessi. PLOS Computational Biology 15 (5): e1006933. https://doi.org/10.1371/journal.pcbi.1006933.
Monaco, Claudia, Jagdeep Nanchahal, Peter Taylor, and Marc Feldmann. 2014. “Anti-TNF Therapy: Past, Present and Future.” International Immunology 27 (1): 55–62. https://doi.org/10.1093/intimm/dxu102.
Morgenthaler, Stephan. 2009. “Exploratory Data Analysis.” WIREs Computational Statistics 1 (1): 33–44. https://doi.org/10.1002/wics.2.